package com.tm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tm.entity.CategoryEntity;
import com.tm.mapper.CategoryMapper;
import com.tm.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author DELL
 * @PROJECT_NAME: tm-wm-syb
 * @DESCRIPTION:
 * @USER: DELL
 * @DATE: 2023/4/4 14:35
 */
@Service
public class CategoryServiceImpl  extends ServiceImpl<CategoryMapper, CategoryEntity> implements CategoryService {

@Resource
private CategoryMapper categoryMapper;

    @Override
    public Page<CategoryEntity> pageList(Integer page, Integer pageSize) {
        QueryWrapper<CategoryEntity> objectQueryWrapper = new QueryWrapper<>();
        Page<CategoryEntity> page1 =new Page<>(page,pageSize);
        Page<CategoryEntity> page2 = super.page(page1);
        Integer count = categoryMapper.selectCount(objectQueryWrapper);
        page2.setTotal(count);
        return page2;
    }

    @Override
    public void deletec(Long ids) {
        categoryMapper.deleteById(ids);
    }
}
